# -*- coding: utf-8 -*-
#
# File: Facility.py
#
# Copyright (c) 2008 by []
# Generator: ArchGenXML Version 2.1
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#

__author__ = """unknown <unknown>"""
__docformat__ = 'plaintext'

from AccessControl import ClassSecurityInfo
from Products.Archetypes.atapi import *
from zope.interface import implements
import interfaces

from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.ATContentTypes.content.newsitem import ATNewsItem
from Products.ATContentTypes.content.newsitem import ATNewsItemSchema
from Products.PloneFacilities.config import *

##code-section module-header #fill in your manual code here
##/code-section module-header

copied_fields = {}
copied_fields['title'] = ATNewsItemSchema['title'].copy()
copied_fields['title'].widget.label = "Facility Name"
copied_fields['description'] = ATNewsItemSchema['description'].copy()
copied_fields['description'].widget.description = "A short description of this facility."
copied_fields['description'].widget.rows = 2
copied_fields['image'] = ATNewsItemSchema['image'].copy()
copied_fields['image'].max_size = (960,960)
copied_fields['image'].widget.label = "Facility Photo"
copied_fields['image'].widget.description = "A thumbnail of this image will be shown"
copied_fields['imageCaption'] = ATNewsItemSchema['imageCaption'].copy()
copied_fields['imageCaption'].widget.label = "Photo Caption"
copied_fields['imageCaption'].widget.description = "The caption will be displayed below the photo"
schema = Schema((

    copied_fields['title'],

    StringField(
        name='locationAddress',
        widget=StringField._properties['widget'](
            label="Street Address",
            label_msgid='PloneFacilities_label_locationAddress',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    StringField(
        name='locationCity',
        default='Raton',
        widget=StringField._properties['widget'](
            label="City",
            label_msgid='PloneFacilities_label_locationCity',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    StringField(
        name='locationState',
        default='NM',
        widget=StringField._properties['widget'](
            label="State",
            maxlength=2,
            size=2,
            label_msgid='PloneFacilities_label_locationState',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    IntegerField(
        name='locationZIP',
        default=87740,
        widget=IntegerField._properties['widget'](
            label="ZIP",
            label_msgid='PloneFacilities_label_locationZIP',
            i18n_domain='PloneFacilities',
        ),
        required=True,
        validators=('isZipCode',),
    ),
    StringField(
        name='mapType',
        default="Yes, automatically create a map",
        widget=SelectionWidget(
            label="Automatically create a map?",
            description="Do you want the system to automatically create a map for this location?",
            label_msgid='PloneFacilities_label_mapType',
            description_msgid='PloneFacilities_help_mapType',
            i18n_domain='PloneFacilities',
        ),
        required=True,
        vocabulary=["Yes, automatically create a map", "No, use my map code below (paste your map code into the Optional Map Code Override field below)", "Don't show any map"],
    ),
    TextField(
        name='embeddableMapCode',
        widget=TextAreaWidget(
            description="Leave blank if you want a map autmatically created for this location.  Otherwise, paste HTML code for the manually created map you want to be shown.",
            label="Optional Map Code Override",
            label_msgid='PloneFacilities_label_embeddableMapCode',
            description_msgid='PloneFacilities_help_embeddableMapCode',
            i18n_domain='PloneFacilities',
        ),
        default_output_type="text/html",
    ),
    LinesField(
        name='hours',
        widget=LinesField._properties['widget'](
            description="Hours of operation for this location",
            label="Hours",
            label_msgid='PloneFacilities_label_hours',
            description_msgid='PloneFacilities_help_hours',
            i18n_domain='PloneFacilities',
        ),
    ),
    LinesField(
        name='fees',
        widget=LinesField._properties['widget'](
            label="Fees",
            description="Costs for this location",
            label_msgid='PloneFacilities_label_fees',
            description_msgid='PloneFacilities_help_fees',
            i18n_domain='PloneFacilities',
        ),
    ),
    StringField(
        name='contactPhone',
        default="(575)",
        widget=StringField._properties['widget'](
            label="Phone",
            description="Contact phone number",
            label_msgid='PloneFacilities_label_contactPhone',
            description_msgid='PloneFacilities_help_contactPhone',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    StringField(
        name='contactEmail',
        widget=StringField._properties['widget'](
            label="Email",
            description="Contact email address",
            label_msgid='PloneFacilities_label_contactEmail',
            description_msgid='PloneFacilities_help_contactEmail',
            i18n_domain='PloneFacilities',
        ),
        validators=('isEmail',),
    ),
    copied_fields['description'],

    copied_fields['image'],

    copied_fields['imageCaption'],


),
)

##code-section after-local-schema #fill in your manual code here
##/code-section after-local-schema

Facility_schema = ATNewsItemSchema.copy() + \
    schema.copy()

##code-section after-schema #fill in your manual code here
##/code-section after-schema

class Facility(ATNewsItem):
    """
    """
    security = ClassSecurityInfo()

    implements(interfaces.IFacility)

    meta_type = 'Facility'
    _at_rename_after_creation = True

    schema = Facility_schema

    ##code-section class-header #fill in your manual code here
    ##/code-section class-header

    # Methods

def modify_fti(fti):
    # Hide unnecessary tabs (usability enhancement)
    for a in fti['actions']:
        if a['id'] in ['metadata']:
            a['visible'] = 0
    return fti

registerType(Facility, PROJECTNAME)
# end of class Facility

##code-section module-footer #fill in your manual code here
##/code-section module-footer



